<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	/**
	 * @author 谭湘元
	 * @since 2009/05/22
	 */

 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>聋校备课与语言学习及矫治系统</title>
<fmt:setBundle basename="PathResource" scope="session" />
<link href="<%=request.getContextPath() %>/<fmt:message key='StylePath' />style2.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/<fmt:message key='jquery' />jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/<fmt:message key='jquery' />jquery.boxy.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/<fmt:message key='jquery' />ajaxHelper.js"></script>
<script type="text/javascript">
	var centerWindow;
	function studentChanged(selct){
		var dialog = getModalDialog(getAjaxSource(),"loading..");
		var _url = "<%=request.getContextPath()%>/game.do?method=changeCurrentStudent";
		$.ajax({
			url:_url,
			type: 'POST',
			dataType: 'xml',
			timeout: 20000,//超时时间设定
			data:'studentID='+selct.value,//参数设置
			error: function(){alert('error');},//错误处理，隐藏进度条
			success: function(xml){
				var html = "";
				$(xml).find("teachbook").each(function(index,obj){
					html+="<tr><td width=\"23%\" align=\"center\" valign=\"middle\"><input type=\"radio\" name=\"teachBookID\" value=\""+$(obj).attr("id")+"\" /></td>";
					html+="<td width=\"77%\" align=\"left\" valign=\"middle\">"+$(obj).attr("name")+"</td></tr>";
				});
				$("#teachBookTable").html(html);
			},
			complete: function(){
				dialog.hide();
				centerWindow.location = centerWindow.location;
			}
			
		});
	}
	function gameTypeChanged(selct){
		var dialog = getModalDialog(getAjaxSource(),"loading..");
		var _url = "<%=request.getContextPath()%>/game.do?method=changeCurrentGameType";
		$.ajax({
			url:_url,
			type: 'POST',
			dataType: 'xml',
			timeout: 20000,//超时时间设定
			data:'gameTypeID='+selct.value,//参数设置
			error: function(){alert('error');},//错误处理，隐藏进度条
			success: function(xml){
				var html = "";
				$(xml).find("game").each(function(index,obj){
					html+="<tr><td width=\"23%\" align=\"center\" valign=\"middle\">";
					html+="<input type=\"radio\" name=\"gameID\"  onclick=\"checkedGame(this);\" value=\""+$(obj).attr("id")+"\" />";
					html+="<input type=\"hidden\" id=\""+$(obj).attr("id")+"\" value=\""+$(obj).find("url").text()+"\" /></td>";
					html+="<td width=\"77%\" align=\"left\" valign=\"middle\">"+$(obj).attr("name")+"</td></tr>";
				});
				$("#gameTable").html(html);
			},
			complete: function(){
				dialog.hide();
				centerWindow.location = centerWindow.location;
			}
			
		});
	}
	function getModalDialog(content,title){
		var dialog = top.eval("new Boxy('"+content+"',{title:'"+title+"',unloadOnHide:true,closeable:false,modal:true});");
		return dialog;
	}
	function checkedGame(obj){
		//var path = $("#"+obj.value).val();
		centerWindow.addFlashToCenter(obj.value);
	}
	function getEvaluateText(){
		var bookId = getCurrentBookId();
		if(bookId=="") return "";
		return $("input[type='hidden'][name='book_"+bookId+"']").val();
	}
	function getCurrentBookId(){
		var result="";
		$("input[type='radio'][name='teachBookID']").each(function(index,obj){
			if(obj.checked){
				result = obj.value;
			}
		});
		return result;
	}
	function getStudentId(){
		return document.forms[0].studentID.value;
	}
	function getGameTypeJustDataType(){
		var gameType = document.forms[0].gameType.value;
		return $("input[type='hidden'][name='gameType_"+gameType+"']").val();
	}
	function getGameId(){
		var result="";
		$("input[type='radio'][name='gameID']").each(function(index,obj){
			if(obj.checked){ 
				result = obj.value
			};
		});
		return result;
	}
	function init(){
		centerWindow = self.parent.frames["center"];
	}
</script>
</head>

<body class="right_style" bgcolor="#ccea68" onload="init();">
<form id="form1" name="form1" method="post" action="">
  <table width="167" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="700" align="left" valign="top" background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/jzxx/right_bg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="20">&nbsp;</td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="34" align="left" ><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/ktyx/right_01.gif" width="145" height="34" /></td>
                  </tr>
                  <tr>
                    <td height="40" align="center" ><table width="100%" border="0" cellspacing="5" cellpadding="0">
                      <tr>
                        <td align="left"><select name="studentID" class="select1" style="width:140px;" onchange="studentChanged(this);">
                  <c:forEach items="#{__rescue_game_resouce_container_key__.studentBookMapping}" var="item">
                              <option value="<c:out value="${item.key.studentId }" />"><c:out value="${item.key.sname }" /></option>
				  </c:forEach>
                             </select>
						</td>
                       </tr></table>
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="34" align="left" ><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/ktyx/right_04.gif" width="145" height="34" /></td>
                  </tr>
                  <tr>
                    <td height="40" align="center" ><table width="100%" border="0" cellspacing="5" cellpadding="0">
                      <tr>
                        <td align="left">
							<select name="gameType" class="select1" style="width:140px;" onchange="gameTypeChanged(this);">
								<c:forEach items="${gameTypes}" var="item">
                              <option value="<c:out value="${item.id}" />" <c:if test="${item.id==__rescue_game_resouce_container_key__.gameType}">selected</c:if> ><c:out value="${item.name }" /></option>
                              	</c:forEach>
                            </select>
							<c:forEach items="${gameTypes}" var="item">
								<input type="hidden" name="gameType_<c:out value="${item.id}" />" value="<c:out value="${item.justDataType}" />" />
                            </c:forEach>
						</td>
                      </tr></table>
                    </td>
                  </tr>
                </table>
                </td>
              </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="left"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/ktyx/right_03.gif" width="166" height="40" border="0" /></td>
                  </tr>
                  <tr>
                    <td><table width="100%" border="0" cellspacing="3" cellpadding="0" >
                        <tr>
                          <td><table width="85%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td height="5" align="center" valign="bottom"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/jzxx/right_top.gif" width="141" height="5" /></td>
                              </tr>
                              <tr>
                                <td align="center" valign="middle" class="right_center"><div style="overflow:scroll; overflow-x:hidden; height:100px; width:130px;">
                                    <table width="100%" border="0" cellspacing="5" cellpadding="0" id="gameTable">
                                      <c:forEach items="${__rescue_game_resouce_container_key__.currentGames}" var="item">
									  <tr>
                                        <td width="23%" align="center" valign="middle"><input type="radio" name="gameID" onclick="checkedGame(this);" value="<c:out value="${item.id}" />" /><%--<input type="hidden" id="<c:out value="${item.id}" />" value="<c:out value="${item.path}" />" />--%></td>
                                        <td width="77%" align="left" valign="middle"><c:out value="${item.name}" /></td>
                                      </tr>
                                      </c:forEach>
                                    </table>
                                </div></td>
                              </tr>
                              <tr>
                                <td height="5" align="center" valign="top"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/jzxx/right_bottom.gif" width="141" height="5" /></td>
                              </tr>
                          </table></td>
                        </tr>
                    </table></td>
                  </tr>
                  
                </table></td>
              </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="left"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/ktyx/right_02.gif" width="166" height="42" border="0" /></td>
                  </tr>
                  <tr>
                    <td><table width="100%" border="0" cellspacing="3" cellpadding="0" >
                        <tr>
                          <td><table width="85%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td height="5" align="center" valign="bottom"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/jzxx/right_top.gif" width="141" height="5" /></td>
                              </tr>
                              <tr>
                                <td align="center" valign="middle" class="right_center"><div style="overflow:scroll; overflow-x:hidden; height:100px; width:130px;">
                                  <table width="100%" border="0" cellspacing="5" cellpadding="0" id="teachBookTable">
                                      <c:forEach items="${__rescue_game_resouce_container_key__.currentTeachBooks}" var="item">
									  <tr>
                                        <td width="23%" align="center" valign="middle"><input type="radio" name="teachBookID" value="<c:out value="${item.bookId }" />" /></td>
                                        <td width="77%" align="left" valign="middle"><c:out value="${item.tbookName }" /><input type="hidden" name="book_<c:out value="${item.bookId }" />" value="<c:out value="${item.scoreText }" />" /></td>
                                      </tr>
                                      </c:forEach>
                                  </table>
                                </div></td>
                              </tr>
                              <tr>
                                <td height="5" align="center" valign="top"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/jzxx/right_bottom.gif" width="141" height="5" /></td>
                              </tr>
                          </table></td>
                        </tr>
                    </table></td>
                  </tr>
                  <%-- <tr>
                    <td><table width="85%" border="0" cellspacing="2" cellpadding="0">
                      <tr>
                        <td align="center"><a href="#" onfocus="this.blur()"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/jzxx/yx_add.gif" width="63" height="22" border="0" /></a></td>
                      </tr>
                    </table></td>
                  </tr>--%>
                </table></td>
              </tr>
            </table></td>
          </tr>
      </table></td>
    </tr>
  </table>
</form>
</body>
</html>
                  